#include <iostream>
#include <memory>
using std::unique_ptr;
using std::cout;
using std::endl;

class CPU{
};
class IntelCPU:public CPU{
public:
    IntelCPU(){
        cout << "create a IntelCPU" << endl;
    }
};
class AMDCPU:public CPU{
public:
    AMDCPU(){
        cout << "create a AMDCPU" << endl;
    }
};

class MainBoard{
};
class IntelMainBoard:public MainBoard{
public:
    IntelMainBoard(){
        cout << "create a Intel MainBoard" << endl;
    }
};
class AMDMainBoard:public MainBoard{
public:
    AMDMainBoard(){
        cout << "create a AMD MainBoard" << endl;
    }
};

class Factory{
public:
    virtual CPU * createCPU()=0;
    virtual MainBoard * createMB()=0;
};


class Intel:public Factory{
public:
    CPU * createCPU()override{
        CPU* p = new IntelCPU();
        return p;
    }
    MainBoard * createMB(){
        MainBoard* p = new IntelMainBoard();
        return p;
    }
};
class AMD:public Factory{
public:
    CPU * createCPU()override{
        CPU* p = new AMDCPU();
        return p;
    }
    MainBoard * createMB(){
        MainBoard* p = new AMDMainBoard();
        return p;
    }
};

void test(){
    unique_ptr<Factory> intel_f(new Intel());
    intel_f->createCPU();
    intel_f->createMB();
    unique_ptr<Factory> amd_f(new AMD());
    amd_f->createCPU();
    amd_f->createMB();

}

int main()
{
    

    test ();
    return 0;
}

